#include "BaseWindow.h"
#include <qevent.h>

BaseWindow::BaseWindow():
	QDialog{ nullptr,Qt::FramelessWindowHint },
	current_btn{ Qt::NoButton },
	current_mouse_point{}
{}

BaseWindow::~BaseWindow()
{}

void BaseWindow::mousePressEvent(QMouseEvent* event)
{
	this->current_btn = event->button();
	this->current_mouse_point = event->globalPosition().toPoint() - this->pos();
}

void BaseWindow::mouseReleaseEvent(QMouseEvent* event)
{
	if (event->button() == this->current_btn)
	{
		this->current_btn = Qt::NoButton;
	}
}

void BaseWindow::mouseMoveEvent(QMouseEvent* event)
{
	if (current_btn == Qt::LeftButton)
	{
		this->move(event->globalPosition().toPoint() - this->current_mouse_point);
	}
}